{extend name='public/base' /}
{block name='content'}
{include file='public/content_header' /}
<style>
    .btn-an{
        display: flex;
        margin-left: 200px;
        justify-content: space-around;
    }
    .btn-an :nth-child(2){
        margin-left: 20px;
    }
    .btn-an a{
        margin: 0 5px;
    }
</style>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <!-- 表单头部 -->
                <div class="box-header with-border">
                    <div class="btn-group">
                        <a class="btn flat btn-sm btn-default BackButton">
                            <i class="fa fa-arrow-left"></i>
                            返回
                        </a>
                        <div class="btn-an">
                        {if isset($data.staff_id) && isset($data.salary_time) && isset($data.department_id)}
                            <label>员工信息</label>
                            <a data-id="{$data.staff_id}" data-time="{$data.salary_time}" data-url="{:url('view')}" data-type="2"  data-confirm="2" data-title="员工固定工资" data-opea="basicSalary"  data-toggle="tooltip" class="infos btn btn-facebook btn-sm AjaxButton">
                                <i class="fa fa-anchor"></i>固定工资
                            </a>
                            <a data-id="{$data.staff_id}" data-time="{$data.salary_time}" data-url="{:url('view')}" data-type="2"  data-confirm="2" data-title="员工绩效" data-opea="performance"  data-toggle="tooltip" class="infos btn btn-reddit btn-sm AjaxButton">
                                <i class="fa fa-bar-chart"></i>绩效
                            </a>
                            <a  data-id="{$data.staff_id}" data-time="{$data.salary_time}" data-url="{:url('view')}" data-type="2"  data-confirm="2" data-title="员工提成" data-opea="commission"  class="infos btn btn-success btn-sm AjaxButton"  data-toggle="tooltip">
                                <i class="fa fa-calculator"></i>提成
                            </a>

                            <a  data-id="{$data.staff_id}" data-time="{$data.salary_time}"  data-url="{:url('view')}" data-type="2"  data-confirm="2" data-opea="attendance"  data-title="员工考勤" class="infos btn btn-warning btn-sm AjaxButton"  data-toggle="tooltip">
                                <i class="fa fa-calendar"></i>考勤
                            </a>
                            <a class="infos btn btn-dropbox btn-sm shengcheng" data-id="{$data.id | default=''}">
                                <i class="fa fa-forward"></i>重新生成
                            </a>
                            {/if}
                        </div>

                    </div>
                </div>
                <!-- 表单 -->
                <form id="dataForm" class="form-horizontal dataForm" action="" method="post"
                      enctype="multipart/form-data" onkeydown="if(event.keyCode===13){return false;}">
                    <!-- 表单字段区域 -->
                    <div class="box-body">
                        <div class="form-group">
                            <label for="salary_time" class="col-sm-2 control-label">工资日期</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="salary_time" name="salary_time" value="{$data.salary_time|default=''}"
                                       placeholder="请选择工资日期" type="text" class="form-control filed-year-month" autocomplete="off">
                            </div>
                        </div>
                        <script>
                            var currentTime ='';
                            if ($('#salary_time').val()){
                                currentTime = $('#salary_time').val();
                            }
                            function getCurrentDate(time) {
                                var now = new Date(time* 1000);
                                var year = now.getFullYear(); //得到年份
                                var month = now.getMonth();//得到月份
                                month = month + 1;
                                if (month < 10) month = "0" + month;
                                return year+'-'+month;
                            }
                            laydate.render({
                                elem: '#salary_time',
                                type: 'month',
                                value:currentTime,
                                btns:[],
                                ready: function (date) {
                                    $(".layui-laydate").on('click', 'ul li', function () {
                                        $(".layui-laydate").remove();
                                    });
                                },
                                change: function (value) {
                                    $("#salary_time").val(value);
                                    if ($('.btn-an a').length > 0) {
                                        $('.btn-an a').each(function (e,v) {

                                            $(v).attr('data-time',value);
                                        })
                                    }
                                    let departmentId = $('#department_id').val();
                                    $('.form-group textarea,input:not("#staff_id"):not("#department_id"):not("#salary_time")').val('');
                                    let time = value;
                                    let option = "SalaryLog";
                                    if (departmentId){
                                        $.ajax({
                                            url: "{:url('performance/getStaffByDepartmentId')}",
                                            type: "post",
                                            data: {"departmentId": departmentId,'time':time,'option':option},
                                            dataType: "json",
                                            sync: false,
                                            success: function (res) {
                                                if (res.code===0){
                                                    layer.alert(res.msg, {
                                                        icon: 0,
                                                        skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
                                                    })
                                                    $('#staff_id').empty();
                                                    return false;
                                                } else {

                                                    $('#staff_id').empty();
                                                    $('#staff_id').append(`<option value=""></option>`);
                                                    var _html = '';
                                                    $.each(res.data,function (e,v) {

                                                        _html  +=
                                                            `<option value="${v.id}">${v.name}</option>`
                                                        ;
                                                    })
                                                    $('#staff_id').append(_html).trigger('change.select2');
                                                    $('#staff_id').select2();
                                                    $('#department_id-error').empty();
                                                    $('#staff_id-error').empty();
                                                    let staff_id = $('#staff_id').select2('val');
                                                    if (staff_id){
                                                        $.ajax({
                                                            url:"{:url('SalaryLog/compose')}",
                                                            data:{'staff_id':staff_id,'salary_time':value},
                                                            type:"POST",
                                                            dataType: "json",
                                                            sync: false,
                                                            success:function (res) {
                                                                console.log(res);
                                                                if (res.code===0){
                                                                    layer.alert(res.msg, {
                                                                        icon: 0,
                                                                    });
                                                                    return false;
                                                                }
                                                                if (res.code===1){
                                                                    $.each(res.data,function (e,v) {
                                                                        if (e=='salary_time'){
                                                                            $("#"+e).val(getCurrentDate(v));
                                                                        }else{
                                                                            $("#"+e).val(v);
                                                                        }
                                                                    })
                                                                }
                                                            }

                                                        })
                                                    }
                                                }
                                            }
                                        })
                                    }
                                },
                            });
                        </script>
                        <div class="form-group">
                            <label for="department_id" class="col-sm-2 control-label">部门</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="department_id" id="department_id" class="form-control field-select"
                                        data-placeholder="请选择部门">
                                    <option value=""></option>
                                    {$department_list|raw}
                                </select>
                            </div>
                        </div>
                        <script>
                            $('#department_id').select2();
                            $('#department_id').change(function () {
                                let departmentId = $(this).val();
                                $('.form-group textarea,input:not("#staff_id"):not("#department_id"):not("#salary_time")').val('');
                                let time = $('#salary_time').val();
                                let option = "SalaryLog";

                                if (time){
                                    $.ajax({
                                        url: "{:url('performance/getStaffByDepartmentId')}",
                                        type: "post",
                                        data: {"departmentId": departmentId,'time':time,'option':option},
                                        dataType: "json",
                                        sync: false,
                                        success: function (res) {
                                            if (res.code===0){
                                                layer.alert(res.msg, {
                                                    icon: 0,
                                                    skin: 'layer-ext-moon' //该皮肤由layer.seaning.com友情扩展。关于皮肤的扩展规则，去这里查阅
                                                })
                                                $('#staff_id').empty();
                                            } else {

                                                $('#staff_id').empty();
                                                $('#staff_id').append(`<option value=""></option>`);
                                                var _html = '';
                                                $.each(res.data,function (e,v) {

                                                    _html  +=
                                                        `<option value="${v.id}">${v.name}</option>`
                                                    ;
                                                })
                                                $('#staff_id').append(_html).trigger('change.select2');
                                                $('#staff_id').select2();
                                                $('#department_id-error').empty();
                                                $('#staff_id-error').empty();
                                            }
                                        }
                                    })
                                }else {
                                    layer.alert('请选择时间',{icon:0})
                                }
                            });

                        </script>

                        <div class="form-group">
                            <label for="staff_id" class="col-sm-2 control-label">员工</label>
                            <div class="col-sm-10 col-md-4">
                                <select name="staff_id" id="staff_id"  class="form-control field-select"
                                        data-placeholder="请选择员工">
                                    {if isset($data)}
                                    <option value=""></option>
                                    {foreach name='staff_list' id='item'}
                                    <option value="{$item.id}" {if isset($data) &&
                                            $data.staff_id==$item.id}selected{/if}>
                                        {$item.name}
                                    </option>
                                    {/foreach}
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-10 col-md-4">
                                <input id="department_name" name="department_name" value="{$data.department_name|default=''}"
                                       placeholder="部门名称" type="hidden" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-10 col-md-4">
                                <input id="insure_id" name="insure_id" value="{$data.insure_id|default=''}"
                                       placeholder="请输入险种" type="hidden" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-10 col-md-4">
                                <input id="id" name="id" value="{$data.id|default=''}"
                                       placeholder="id" type="hidden" class="form-control field-text">
                            </div>
                        </div>
                        <script>
                            $('#staff_id').select2();
                            $('#staff_id').on("select2:open",function (e) {
                                if ($("#department_id").val() === ''){
                                        layer.alert('请先选择部门', {
                                            icon: 0,
                                        })
                                }
                            });
                            function compose(staff_id,time,id=''){
                                var index = layer.load(2, {
                                    shade: [0.6,'#000'] //0.1透明度的白色背景
                                });
                                $.ajax({
                                        url:"{:url('SalaryLog/compose')}",
                                        data:{'staff_id':staff_id,'salary_time':time,'id':id},
                                        type:"POST",
                                        dataType: "json",
                                        sync: false,
                                        success:function (res) {
                                            if (res.code===0){
                                                if (res.data !='' && res.data.id != undefined){
                                                    if (res.data.id != undefined){
                                                        $('.shengcheng').attr('data-id',res.data.id);
                                                    }
                                                    $.each(res.data,function (e,v) {
                                                        $("#"+e).val(v);
                                                    })
                                                }else {
                                                   $('.form-group textarea,input:not(".staff_id"):not(".department_id"):not(".salary_time")').val('');
                                                }

                                                layer.alert(res.msg, {
                                                    icon: 0,
                                                });
                                                layer.closeAll('loading');
                                                return false;
                                            }
                                            if (res.code===1){
                                                $.each(res.data,function (e,v) {
                                                    if (e=='salary_time'){
                                                        $("#"+e).val(getCurrentDate(v));
                                                    }else{
                                                        $("#"+e).val(v);
                                                    }
                                                })
                                                layer.closeAll('loading');
                                            }
                                        }

                                    })


                            }

                            $("#staff_id").on('change',function (e) {
                                let staff_id = $('#staff_id').select2('val');
                                let time = $("#salary_time").val();
                                $('.btn-an').empty();
                                $('.btn-an').append(`
                                <label>员工信息</label>
                                 <a data-id="${staff_id}" data-time="${time}" data-url="view" data-type="2"  data-confirm="2" data-title="员工固定工资" data-opea="basicSalary"  data-toggle="tooltip" class="infos btn btn-facebook btn-sm AjaxButton">
                                <i class="fa fa-anchor"></i>固定工资
                            </a>
                            <a data-id="${staff_id}" data-time="${time}" data-url="view" data-type="2"  data-confirm="2" data-title="员工绩效" data-opea="performance"  data-toggle="tooltip" class="infos btn btn-reddit btn-sm AjaxButton">
                                <i class="fa fa-bar-chart"></i>绩效
                            </a>
                            <a  data-id="${staff_id}" data-time="${time}" data-url="view" data-type="2"  data-confirm="2" data-title="员工提成" data-opea="commission"  class="infos btn btn-success btn-sm AjaxButton"  data-toggle="tooltip">
                                <i class="fa fa-calculator"></i>提成
                            </a>

                            <a  data-id="${staff_id}" data-time="${time}"  data-url="view" data-type="2"  data-confirm="2" data-opea="attendance"  data-title="员工考勤" class="infos btn btn-warning btn-sm AjaxButton"  data-toggle="tooltip">
                                <i class="fa fa-calendar"></i>考勤
                            </a>
                             <a class="infos btn btn-dropbox btn-sm shengcheng">
                                <i class="fa fa-forward"></i>重新生成
                            </a>
                                `);
                              compose(staff_id,time);
                            })

                        </script>
                        <div class="form-group">
                            <label for="basic_salary" class="col-sm-2 control-label">基本工资</label>
                                <div class="col-sm-10 col-md-4">
                                    <div class="input-group">
                                        <input id="basic_salary" name="basic_salary" value="{$data.basic_salary|default=''}"
                                           placeholder="请输入基本工资" type="number" class="form-control field-number">
                                    </div>
                                </div>
                        </div>
<!--                        <script>-->
<!--                            $('#basic_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="manage_salary" class="col-sm-2 control-label">管理工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="manage_salary" name="manage_salary"
                                           value="{$data.manage_salary|default=''}" placeholder="请输入管理工资" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#manage_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="title_salary" class="col-sm-2 control-label">职称津贴</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="title_salary" name="title_salary" value="{$data.title_salary|default=''}"
                                           placeholder="请输入职称津贴" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#title_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="education_salary" class="col-sm-2 control-label">学历津贴</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="education_salary" name="education_salary"
                                           value="{$data.education_salary|default=''}" placeholder="请输入学历津贴"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#education_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="nightwork_salary" class="col-sm-2 control-label">夜班津贴</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="nightwork_salary" name="nightwork_salary"
                                           value="{$data.nightwork_salary|default=''}" placeholder="请输入夜班津贴"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#nightwork_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="payscale_salary" class="col-sm-2 control-label">薪级津贴</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="payscale_salary" name="payscale_salary"
                                           value="{$data.payscale_salary|default=''}" placeholder="请输入薪级津贴"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#payscale_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="secret_salary" class="col-sm-2 control-label">保密工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="secret_salary" name="secret_salary"
                                           value="{$data.secret_salary|default=''}" placeholder="请输入保密工资" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#secret_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="overtime_salary" class="col-sm-2 control-label">加班工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="overtime_salary" name="overtime_salary"
                                           value="{$data.overtime_salary|default=''}" placeholder="请输入加班工资"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#overtime_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="fulltime_salary" class="col-sm-2 control-label">全勤奖</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="fulltime_salary" name="fulltime_salary"
                                           value="{$data.fulltime_salary|default=''}" placeholder="请输入全勤奖" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#fulltime_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="phone_salary" class="col-sm-2 control-label">通讯补助</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="phone_salary" name="phone_salary" value="{$data.phone_salary|default=''}"
                                           placeholder="请输入通讯补助" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#phone_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="housing_salary" class="col-sm-2 control-label">住房补贴</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="housing_salary" name="housing_salary"
                                           value="{$data.housing_salary|default=''}" placeholder="请输入住房补贴" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#housing_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="other_salary" class="col-sm-2 control-label">其他补助</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="other_salary" name="other_salary" value="{$data.other_salary|default=''}"
                                           placeholder="请输入其他补助" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#other_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="base_merit_salary" class="col-sm-2 control-label">绩效工资基数</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="base_merit_salary" name="base_merit_salary"
                                           value="{$data.base_merit_salary|default=''}" placeholder="请输入绩效工资基数"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#base_merit_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="total_fixed_salary" class="col-sm-2 control-label">固定工资合计</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="total_fixed_salary" name="total_fixed_salary"
                                           value="{$data.total_fixed_salary|default=''}" placeholder="请输入固定工资合计"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#total_fixed_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="merit_salary" class="col-sm-2 control-label">绩效工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="merit_salary" name="merit_salary" value="{$data.merit_salary|default=''}"
                                           placeholder="请输入绩效工资" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#merit_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->

                        <div class="form-group">
                            <label for="real_total_fixed_salary" class="col-sm-2 control-label">实际固定工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="real_total_fixed_salary" name="real_total_fixed_salary" value="{$data.real_total_fixed_salary|default=''}" placeholder="请输入实际固定工资" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#real_total_fixed_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->

                        <div class="form-group">
                            <label for="commission" class="col-sm-2 control-label">提成</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="commission" name="commission" value="{$data.commission|default=''}"
                                           placeholder="请输入提成" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#commission')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="live_commission" class="col-sm-2 control-label">直播提成</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="live_commission" name="live_commission"
                                           value="{$data.live_commission|default=''}" placeholder="请输入直播提成"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#live_commission')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="bonus_penalty" class="col-sm-2 control-label">奖惩</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="bonus_penalty" name="bonus_penalty"
                                           value="{$data.bonus_penalty|default=''}" placeholder="请输入奖惩" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#bonus_penalty')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="late_cut" class="col-sm-2 control-label">迟到扣款</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="late_cut" name="late_cut" value="{$data.late_cut|default=''}"
                                           placeholder="请输入迟到扣款" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#late_cut')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="sick_allowance" class="col-sm-2 control-label">病假补助</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="sick_allowance" name="sick_allowance"
                                           value="{$data.sick_allowance|default=''}" placeholder="请输入病假补助" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#sick_allowance')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="absence_leave_cut" class="col-sm-2 control-label">事假扣款</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="absence_leave_cut" name="absence_leave_cut"
                                           value="{$data.absence_leave_cut|default=''}" placeholder="请输入事假扣款"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#absence_leave_cut')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="absenteeism_cut" class="col-sm-2 control-label">旷工扣款</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="absenteeism_cut" name="absenteeism_cut"
                                           value="{$data.absenteeism_cut|default=''}" placeholder="请输入旷工扣款"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#absenteeism_cut')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="storage_time_cash" class="col-sm-2 control-label">存班折现</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="storage_time_cash" name="storage_time_cash"
                                           value="{$data.storage_time_cash|default=''}" placeholder="请输入存班折现"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#storage_time_cash')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="travel_allowance" class="col-sm-2 control-label">交通补助</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="travel_allowance" name="travel_allowance"
                                           value="{$data.travel_allowance|default=''}" placeholder="请输入交通补助"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#travel_allowance')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="repair_miss_card_cut" class="col-sm-2 control-label">补/缺卡扣款</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="repair_miss_card_cut" name="repair_miss_card_cut" value="{$data.repair_miss_card_cut|default=''}" placeholder="请输入补/缺卡扣款" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#repair_miss_card_cut')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->

                        <div class="form-group">
                            <label for="other" class="col-sm-2 control-label">其他项</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="other" name="other" value="{$data.other|default=''}" placeholder="请输入其他项"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#other')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="total_payoff" class="col-sm-2 control-label">应发工资合计</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="total_payoff" name="total_payoff" value="{$data.total_payoff|default=''}"
                                           placeholder="请输入应发工资合计" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#total_payoff')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="social_security_salary" class="col-sm-2 control-label">社保工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="social_security_salary" name="social_security_salary"
                                           value="{$data.social_security_salary|default=''}" placeholder="请输入社保工资"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#social_security_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="deduct_social_money" class="col-sm-2 control-label">扣社保</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="deduct_social_money" name="deduct_social_money"
                                           value="{$data.deduct_social_money|default=''}" placeholder="请输入扣社保"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#deduct_social_money')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="taxable_salary" class="col-sm-2 control-label">计税工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="taxable_salary" name="taxable_salary"
                                           value="{$data.taxable_salary|default=''}" placeholder="请输入计税工资" type="number"
                                           class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#taxable_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="personal_tax" class="col-sm-2 control-label">个人所得税</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="personal_tax" name="personal_tax" value="{$data.personal_tax|default=''}"
                                           placeholder="请输入个人所得税" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#personal_tax')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="after_tax_insurance_salary" class="col-sm-2 control-label">税后险后工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="after_tax_insurance_salary" name="after_tax_insurance_salary"
                                           value="{$data.after_tax_insurance_salary|default=''}" placeholder="请输入税后险后工资"
                                           type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#after_tax_insurance_salary')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="personal_pay" class="col-sm-2 control-label">个人发放</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="personal_pay" name="personal_pay" value="{$data.personal_pay|default=''}"
                                           placeholder="请输入个人发放" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#personal_pay')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="real_pay" class="col-sm-2 control-label">实发工资</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="real_pay" name="real_pay" value="{$data.real_pay|default=''}"
                                           placeholder="请输入实发工资" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#real_pay')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->
                        <div class="form-group">
                            <label for="cut_cash" class="col-sm-2 control-label">扣款</label>
                            <div class="col-sm-10 col-md-4">
                                <div class="input-group">
                                    <input id="cut_cash" name="cut_cash" value="{$data.cut_cash|default=''}"
                                           placeholder="请输入扣款" type="number" class="form-control field-number">
                                </div>
                            </div>
                        </div>
<!--                        <script>-->
<!--                            $('#cut_cash')-->
<!--                                .bootstrapNumber({-->
<!--                                    upClass: 'success',-->
<!--                                    downClass: 'primary',-->
<!--                                    center: true-->
<!--                                });-->
<!--                        </script>-->

                        <div class="form-group">
                            <label for="remarks" class="col-sm-2 control-label">备注</label>
                            <div class="col-sm-10 col-md-4">
                                <textarea id="remarks" name="remarks" rows="4"   class="form-control field-text"></textarea>
                            </div>
                        </div>
                        <script>
                            $(function () {
                                {if isset($data.remarks)}
                                $("#remarks").val("{$data.remarks}");
                                {/if}
                                })
                        </script>
                        <div class="form-group">
                            <label for="card_name" class="col-sm-2 control-label">发放工资姓名</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="card_name" name="card_name" value="{$data.card_name|default=''}"
                                       placeholder="请输入发放工资姓名" type="text" class="form-control field-text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="card_num" class="col-sm-2 control-label">工资卡号</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="card_num" name="card_num" value="{$data.card_num|default=''}"
                                       placeholder="请输入工资卡号" type="text" class="form-control field-text">
                            </div>
                        </div>

                        <div class="form-group">
                            <label for="file" class="col-sm-2 control-label">附件</label>
                            <div class="col-sm-10 col-md-4">
                                <input id="file" name="file[]" placeholder="请上传附件" multiple="multiple" type="file"
                                       class="form-control field-multi-image">
                            </div>
                        </div>
                        <script>
                            $(function () {
                                $('#file').fileinput({
                                    "initialPreview": false,
                                    overwriteInitial: true,
                                    language: 'zh',
                                    browseLabel: '浏览',
                                    initialPreviewAsData: true,
                                    initialPreviewShowDelete: false,
                                    dropZoneEnabled: false,
                                    showUpload: false,
                                    showRemove: false,
                                    allowedFileTypes: ['image'],
                                    //默认限制10M
                                    maxFileSize: 10240,
                                {if isset($data) && isset($data->file) &&$data->getData('file')}
                                initialPreview:{$data->getData('file')|raw},
                                {/if}
                                });
                            })
                        </script>

                        <div class="form-group">
                            <label for="info" class="col-sm-2 control-label">计算详情</label>
                            <div class="col-sm-10 col-md-4">
                                <textarea id="info" name="info" rows="12" readonly="readonly"  class="form-control field-text"></textarea>
                            </div>
                        </div>
                        <script>
                            $(function () {
                                {if isset($data.info)}
                                    $("#info").val("{$data.info}");
                                {/if}
                            })
                        </script>
                        <div class="form-group">
                            <label for="status" class="col-sm-2 control-label">状态</label>
                            <div class="col-sm-10 col-md-4">
                                <input class="input-switch" id="status" name="status" value="1" {if(!isset($data.status)
                                       ||$data.status==1)}checked{/if} type="checkbox"/>
                                <input class="switch field-switch" placeholder="状态" name="status"
                                       value="{$data.status|default='1'}" hidden/>
                            </div>
                        </div>

                        <script>
                            $('#status').bootstrapSwitch({
                                onText: "是",
                                offText: "否",
                                onColor: "success",
                                offColor: "danger",
                                onSwitchChange: function (event, state) {
                                    $(event.target).closest('.bootstrap-switch').next().val(state ? '1' : '0').change();
                                }
                            });
                        </script>
                    </div>
                    <!-- 表单底部 -->
                    <div class="box-footer">
                        {:token()}
                        <div class="col-sm-2">
                        </div>
                        <div class="col-sm-10 col-md-4">
                            {if !isset($data)}
                            <div class="btn-group pull-right">
                                <label class="createContinue">
                                    <input type="checkbox" value="1" id="_create" name="_create"
                                           title="继续添加数据">继续添加</label>
                            </div>
                            {/if}
                            <div class="btn-group">
                                <button type="submit" class="btn flat btn-info dataFormSubmit">
                                    保存
                                </button>
                            </div>
                            <div class="btn-group">
                                <button type="reset" class="btn flat btn-default dataFormReset">
                                    重置
                                </button>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</section>
<script>
    $(function () {
        var url = window.location.href;
        let staff_id = $('#staff_id').select2('val');
        let time = $("#salary_time").val();
        var val = $('#staff_id').val();
        if (val != null && url.indexOf('add')>=0 ){

            compose(staff_id,time);
        }

        $('.box-header').on('click','.shengcheng',function () {

            let staff_id = $('#staff_id').select2('val');
            let time = $("#salary_time").val();
            let id = $(this).data('id');
            if (id==undefined){
            layer.alert('员工信息不完整',{icon:0});return false;
            }else {
                compose(staff_id,time,id);
            }
        });
    });

    /** 表单验证 **/

    $('#dataForm').validate({
        rules: {
            'staff_id': {
                required: true,
            },
            'card_name': {
                required: true,
            },
            'card_num': {
                required: true,
            },
            'status': {
                required: true,
            },

        },
        messages: {
            'staff_id': {
                required: "员工id不能为空",
            },
            'card_name': {
                required: "发放工资姓名不能为空",
            },
            'card_num': {
                required: "工资卡号不能为空",
            },
            'status': {
                required: "状态不能为空",
            },

        }
    });
</script>
{/block}